/**
 * 2011-11-15上午10:23:00
 */
package dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import util.MysqlConn;
import bean.User;

/**
 * @author Baicai 在显示商品信息的地方查询关联的用户信息
 */
public class GoodsViewUser {

	/**
	 * 根据用户id获取用户的部分信息
	 * 
	 * @param i
	 * @return User
	 */
	public static User getGoodsUser(int i) {

		try {

			User user = new User();
			MysqlConn
					.setSqlString("select userinfo_name,user_score,user_phone from user where user_id='"
							+ i + "'");// 拼接字符串
			ResultSet resultSet = MysqlConn.queryDB();
			resultSet.next();// 取结果集
			user.setUserId(i);
			user.setUserinfoName(resultSet.getString("userinfo_name"));
			user.setUserScore(Integer.parseInt(resultSet
					.getString("user_score")));
			user.setUserPhone(resultSet.getString("user_phone"));

			return user;

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			MysqlConn.free();
		}

		return null;
	}
}
